package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceCarMove;
import com.ruoyi.service.service.IServiceCarMoveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小区挪车Controller
 * 
 * @author yepanpan
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/service/carMove")
public class ServiceCarMoveController extends BaseController
{
    @Autowired
    private IServiceCarMoveService serviceCarMoveService;

    /**
     * 查询小区挪车列表
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceCarMove serviceCarMove)
    {
        startPage();
        List<ServiceCarMove> list = serviceCarMoveService.selectServiceCarMoveList(serviceCarMove);
        return getDataTable(list);
    }

    /**
     * 导出小区挪车列表
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:export')")
    @Log(title = "小区挪车", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceCarMove serviceCarMove)
    {
        List<ServiceCarMove> list = serviceCarMoveService.selectServiceCarMoveList(serviceCarMove);
        ExcelUtil<ServiceCarMove> util = new ExcelUtil<ServiceCarMove>(ServiceCarMove.class);
        util.exportExcel(response, list, "小区挪车数据");
    }

    /**
     * 获取小区挪车详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serviceCarMoveService.selectServiceCarMoveById(id));
    }

    /**
     * 新增小区挪车
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:add')")
    @Log(title = "小区挪车", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody ServiceCarMove serviceCarMove)
    {
                serviceCarMove.setCreateBy(getUsername());
        return toAjax(serviceCarMoveService.insertServiceCarMove(serviceCarMove));
    }

    /**
     * 修改小区挪车
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:edit')")
    @Log(title = "小区挪车", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody ServiceCarMove serviceCarMove)
    {
                serviceCarMove.setUpdateBy(getUsername());
        return toAjax(serviceCarMoveService.updateServiceCarMove(serviceCarMove));
    }

    /**
     * 删除小区挪车
     */
    @PreAuthorize("@ss.hasPermi('service:carMove:remove')")
    @Log(title = "小区挪车", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceCarMoveService.deleteServiceCarMoveByIds(ids));
    }
}
